package com.leetcode.weekly.contest.no281th;

/**
 * @author 覃国强
 * @date 2022-02-20 10:52
 */
public class A01_统计各位数字之和为偶数的整数个数 {

  static
  class Solution {
    public int countEven(int num) {

      int result = 0;
      for (int i = 2; i <= num; ++i) {
        if (isValid(i)) {
          ++result;
        }
      }
      return result;
    }

    public boolean isValid(int num) {
      int sum = 0;
      while (num > 0) {
        sum += (num % 10);
        num /= 10;
      }
      return sum % 2 == 0;
    }
  }

}
